<?xml version="1.0"?>
<jsp:root 	xmlns:jsp="http://java.sun.com/JSP/Page"
 			xmlns:c="http://java.sun.com/jsp/jstl/core"
 			xmlns="http://www.w3.org/1999/xhtml"
 			version="2.1">
 
 <jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
 <jsp:directive.page isELIgnored="false" />
 <jsp:output 	omit-xml-declaration="false" 
 			 	doctype-root-element="HTML" 
 				doctype-system="about:legacy-compat" />
 
 <jsp:useBean id="datosLogin" class="es.javamyadmin.beans.LoginBean" scope="session" />
 
 <jsp:useBean id="listaTriggerBean" class="es.javamyadmin.beans.ListaTriggersBean" scope="session" />
 
 <jsp:setProperty property="user" name="listaTriggerBean" value="${datosLogin.usuario}" />
 <jsp:setProperty property="pass" name="listaTriggerBean" value="${datosLogin.password}" />
 <jsp:setProperty property="host" name="listaTriggerBean" value="${datosLogin.servidor}" />
 <jsp:setProperty property="port" name="listaTriggerBean" value="${datosLogin.puerto}" />
 <jsp:setProperty property="database" name="listaTriggerBean" value="${listaTablesBean.database}" />

<html>
<head>

<link rel="icon" href="${pageContext.request.contextPath}/images/icons/favicon.png" type="image/x-icon"/>
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/icons/favicon.png" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/reset.css" media="screen" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/java-admin.css" media="screen" />

<script src="${pageContext.request.contextPath}/js/jquery.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/bootstrap-transition.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/bootstrap-modal.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/ajaxCargarMsjConfirmacion.js"><!-- N --></script>

<title>JavaMyAdmin</title>

<script>
	$(document).ready(function() {
		$('#windowTitleDialog').bind('show', function () {
			
		});
	});
	function closeDialog () {
		$('#windowTitleDialog').modal('hide'); 
	};
	function okClicked () {
		closeDialog ();
	};	
</script>


<script language="Javascript"> 
var idForm = "";
</script>
</head>


<body onload="cargarTablas('${listaTablesBean.user}','${listaTablesBean.pass}','${listaTablesBean.host}','${listaTablesBean.port}','${listaTablesBean.database}')">

<div id="wrapper">
<div id="todo">

<div id="contenedor">
	
	<jsp:include page="../includes/sidebar-left.jsp" />
	
	<div id="contenido">
	
		<jsp:include page="../includes/cabecera.jsp" />
		
		<h2>Base de Datos: <c:out value="${listaTablesBean.database}"></c:out> >> Tabla: <c:out value="${param.tabla}"></c:out></h2>
		
		<jsp:include page="../includes/menu-superior-alternativo.jsp" />
		
		<!-- Errores -->
		<c:if test="${error!=null}"><div class="aviso"><div class="pro_aviso ko"><p><c:out value="${error}"></c:out></p></div></div></c:if>		
		<c:if test="${ok!=null}"><div class="aviso"><div class="pro_aviso ok"><p><c:out value="${ok}"></c:out></p></div></div></c:if>
		
		<!-- VENTANA EMERGENTE DE CONFIRMACIÓN -->
		<div id="windowTitleDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="windowTitleLabel" aria-hidden="true">
			<div class="modal-header">
        		<a href="#" class="close" data-dismiss="modal">×</a>
        		<h3>ATENCIÓN</h3>
       		</div>
        	<div class="modal-body">
       			<div class="divDialogElements">
        			<p>¿Está seguro de que quiere ELIMINAR el Trigger?</p>
        			<p>Le recordamos que esta acción es irrevocable.</p>
      			</div>
        	</div>
        	<div class="modal-footer">
      			<a href="#" class="btn" onclick="closeDialog ();">Cancelar</a>
      			<a class="btn btn-primary" onclick="idForm.submit()">Aceptar</a>
       		</div>      	
		</div>
		<!-- FIN VENTANA EMERGENTE -->
		
		<table id="lista-tablas">		
			<tr>
				<th style='border-radius: 5px 0 0 0;'>ELIMINAR</th>
				<th>NOMBRE</th>
				<th>EVENTO</th>
				<th>TABLA</th>
				<th>ESTAMENTO</th>
				<th>TIMING</th>
				<th>CREATED</th>
				<th>SQL MODE</th>
				<th>DEFINICION</th>
				<th>CHARACTER SET CLIENTE</th>
				<th>COLLATION CONNECTION</th>
				<th style='border-radius: 0 5px 0 0;'>DATABASE COLLATION</th>
			</tr>

			<c:forEach var="lista" items="${listaTriggerBean.triggers}" varStatus="estado">
				<c:set var="vacia" value="fals"/>
				<form action="${pageContext.request.contextPath}/triggerEditor" method="post" onsubmit="return #windowTitleDialog" name="form${estado.index }">
				<input type="hidden" name="database" value="${listaTablesBean.database}" />
				<input type="hidden" name="user" value="${listaTablesBean.user}" />
				<input type="hidden" name="pass" value="${listaTablesBean.pass}" />
				<input type="hidden" name="host" value="${listaTablesBean.host}" />
				<input type="hidden" name="port" value="${listaTablesBean.port}" />
				<input type="hidden" name="accion" value="delete" />
				<input type="hidden" name="trigger" value="${lista.nombre}" />
				<tr>
					<td style="cursor: default;" align="center"><a data-toggle="modal" href="#windowTitleDialog" onclick="idForm = form${estado.index };" title="eliminar usuario"><img type="image" style="cursor: pointer;" class="margen" src="${pageContext.request.contextPath}/images/icons/delete.png" alt="eliminar"/></a></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.nombre}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.evento}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.tabla}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.estamento}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.timing}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.sqlMode}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.definidcion}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.character}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.collation}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.created}"></c:out></td>
					<td style="cursor: default;" align="center"><c:out value="${lista.databaseCollation}"></c:out></td>
				</tr>
			</form>
			</c:forEach>
			<c:if test="${vacia == null or vacia != 'fals' }">
				<tr>
					<td align="center" colspan="12">No existe ningun trigger para esta base de datos</td>
				</tr>
			</c:if>
	 	</table>
	 		
	</div>

</div>

</div>
</div>
</body>
</html>
</jsp:root>